package org.zn.note.mybatis.core.proxy;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Jdk静态代理
 * 就是代理类和被代理类的关系写死了
 */
public class JdkStaticProxy implements HelloService {

    private final HelloService helloService;

    JdkStaticProxy(HelloService helloService) {
        this.helloService = helloService;
    }

    @Override
    public void sayHello(String name) {
        System.out.printf("Start HelloStaticProxy.sayHello !\n");
        helloService.sayHello(name);
        System.out.printf("Finish HelloStaticProxy.sayHello !\n");
    }

    public static void main(String[] args) {
        HelloService service = new HelloServiceImpl(); // 实际实现对象
        HelloService proxy = new JdkStaticProxy(service); // 代理类，持有实际实现对象
        proxy.sayHello("zzz");
    }
}